//package cn.flying.cloud.demo;
//
//import cn.flying.cloud.base.common.utils.Ft;
//import cn.flying.cloud.base.common.utils.date.DateTimeUtil;
//import cn.flying.cloud.base.common.vo.Rt;
//import cn.flying.cloud.task.core.handler.JobHandlerController;
//import org.springframework.batch.core.Job;
//import org.springframework.batch.core.JobExecution;
//import org.springframework.batch.core.JobParameters;
//import org.springframework.batch.core.JobParametersBuilder;
//import org.springframework.batch.core.configuration.JobLocator;
//import org.springframework.batch.core.launch.JobLauncher;
//import org.springframework.batch.core.launch.JobOperator;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.UUID;
//
///**
// * @author: admin
// * @date: 2025年03月15日 20:58
// * @version: 1.0
// */
//@Component
//public class TaskRunner implements ApplicationRunner {
//
//    @Resource
//    private JobLauncher jobLauncher;
//    @Resource
//    private JobLocator jobLocator;
//    @Resource
//    private JobOperator jobOperator;
//
//    /**
//     * @param args
//     * @throws Exception
//     */
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
////        String serialNo = Ft.DateTime.formatLocalDateTime(LocalDateTime.now(), DateTimeUtil.DATE_TIME_FORMAT_1);
//        String serialNo = "20250321153147477";
//        System.out.println("流水号：" + serialNo);
//        Job job = jobLocator.getJob("jobExample");
//        JobParameters jobParameters = new JobParametersBuilder()
//                .addString("description", "测试任务")
//                .addString("serialNo", serialNo)
//                .addString("jobDate", Ft.DateTime.formatLocalDate(LocalDate.now(), "yyyyMMdd"))
//                .addString("tenantId", "10000")
//                .toJobParameters();
//        // 启动执行批量任务
//        JobExecution execution = jobLauncher.run(job, jobParameters);
//        System.out.println("结果：");
//        System.out.println(execution);
//
//        // JobInstance = Job + JobParameters
//        // 根据执行ID（上一次未完成的执行ID或者实例ID）查询Job和JobParameters参数信息，注意这个只能重启状态为未完成的，已经完成的如果需要重复执行，需要修改参数
////        Long restart = jobOperator.restart(33L);
////        System.out.println(restart);
//    }
//}
